public class Test5 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new TestThread("子线程");
        System.out.printf("当前的线程数为：%d%n", Thread.activeCount());
//        thread.start(); // 2 子线程 3
        thread.run(); // 2 main 2
        thread.join();
    }
}

class TestThread extends Thread {
    public TestThread() {
    }

    public TestThread(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
        System.out.printf("当前的线程数为：%d%n", Thread.activeCount());

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}